import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },
  {
    path: '/JCLines',
    name: 'JCLines',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "JCLines" */ '../views/mes/JCLines/index.vue')
  },
  {
    path: '/THLines',
    name: 'THLines',
    component: () => import(/* webpackChunkName: "JCLines" */ '../views/mes/THLines/index.vue')
  },
  {
    path: '/LVTLines',
    name: 'LVTLines',
    component: () => import(/* webpackChunkName: "JCLines" */ '../views/mes/LVTLines/index.vue')
  },
  {
    path: '/LMHHLines',
    name: 'LMHHLines',
    component: () => import(/* webpackChunkName: "JCLines" */ '../views/mes/LMHHLines/index.vue')
  },
  {
    path: '/KeepingArea',
    name: 'KeepingArea',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "THLines" */ '../views/mes/KeepingArea/index.vue')
  },
  {
    path: '/mesLVTFeeding',
    name: 'mesLVTFeeding',
    component: () => import(/* webpackChunkName: "mesLVTFeeding" */ '../views/mes/mesLVTFeeding/mesLVTFeeding')
  },
  {
    path: '/JCLines1',
    name: 'JCLines1',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "JCLines1" */ '../views/mes/JCLines/index1.vue')
  },
  {
    path: '/THLines1',
    name: 'THLines1',
    component: () => import(/* webpackChunkName: "JCLines1" */ '../views/mes/THLines/index1.vue')
  },
  {
    path: '/KeepingArea1',
    name: 'KeepingArea1',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "KeepingArea1" */ '../views/mes/KeepingArea/index1.vue')
  },
  {
    path: '/mesLVTFeeding1',
    name: 'mesLVTFeeding1',
    component: () => import(/* webpackChunkName: "mesLVTFeeding1" */ '../views/mes/mesLVTFeeding/mesLVTFeeding1')
  },
  {
    path: '/stayDeliveryInfo',
    name: 'stayDeliveryInfo',
    component: () => import(/* webpackChunkName: "stayDeliveryInfo" */ '../views/wms/stayDeliveryInfo/stayDeliveryInfo')
  },
  {
    path: '/stayDeliveryInfo1',
    name: 'stayDeliveryInfo1',
    component: () => import(/* webpackChunkName: "stayDeliveryInfo1" */ '../views/wms/stayDeliveryInfo/stayDeliveryInfo1')
  },
  {
    path: '/materielStorage',
    name: 'materielStorage',
    component: () => import(/* webpackChunkName: "materielStorage" */ '../views/wms/materielStorage/materielStorage')
  },
  {
    path: '/materielStorage1',
    name: 'materielStorage1',
    component: () => import(/* webpackChunkName: "materielStorage1" */ '../views/wms/materielStorage/materielStorage1')
  },
  {
    path: '/inventoryInforSummary',
    name: 'inventoryInforSummary',
    component: () => import(/* webpackChunkName: "inventoryInforSummary" */ '../views/wms/inventoryInforSummary/inventoryInforSummary')
  },
  {
    path: '/finishingProductionLine',
    name: 'finishingProductionLine',
    component: () => import(/* webpackChunkName: "finishingProductionLine" */ '../views/wms/finishingProductionLine/finishingProductionLine')
  },
  {
    path: '/finishingProductionLine1',
    name: 'finishingProductionLine1',
    component: () => import(/* webpackChunkName: "finishingProductionLine1" */ '../views/wms/finishingProductionLine/finishingProductionLine1')
  },
  {
    path: '/mobilePhoneScreen',
    name: 'mobilePhoneScreen',
    component: () => import(/* webpackChunkName: "mobilePhoneScreen" */ '../views/mobileScreen/mobilePhoneScreen')
  },
  {
    path: '/mobilePhoneScreen1',
    name: 'mobilePhoneScreen1',
    component: () => import(/* webpackChunkName: "mobilePhoneScreen1" */ '../views/mobileScreen/mobilePhoneScreen1')
  },
  {
    path: '/extrudeInAndOut',
    name: 'extrudeInAndOut',
    component: () => import(/* webpackChunkName: "extrudeInAndOut" */ '../views/wms/extrudeInAndOut/extrudeInAndOut')
  },
  {
    path: '/extrudeInAndOut1',
    name: 'extrudeInAndOut1',
    component: () => import(/* webpackChunkName: "extrudeInAndOut1" */ '../views/wms/extrudeInAndOut/extrudeInAndOut1')
  },
  {
    path: '/finishedLocation',
    name: 'finishedLocation',
    component: () => import(/* webpackChunkName: "finishedLocation" */ '../views/wms/finishedLocation/finishedLocation')
  },
  {
    path: '/finishedLocation1',
    name: 'finishedLocation1',
    component: () => import(/* webpackChunkName: "finishedLocation1" */ '../views/wms/finishedLocation/finishedLocation1')
  },
  {
    path: '/FGLocation',
    name: 'FGLocation',
    component: () => import(/* webpackChunkName: "FGLocation" */ '../views/wms/finishedLocation/FGLocation')
  },
  {
    path: '/FGLocation1',
    name: 'FGLocation1',
    component: () => import(/* webpackChunkName: "FGLocation1" */ '../views/wms/finishedLocation/FGLocation1')
  },
  {
    path: '/shippingInfor',
    name: 'shippingInfor',
    component: () => import(/* webpackChunkName: "shippingInfor" */ '../views/wms/shippingInfor/shippingInfor')
  },
  {
    path: '/shippingInfor1',
    name: 'shippingInfor1',
    component: () => import(/* webpackChunkName: "shippingInfor1" */ '../views/wms/shippingInfor/shippingInfor1')
  },
  {
    path: '/warehouseLocation',
    name: 'warehouseLocation',
    component: () => import(/* webpackChunkName: "warehoseLocation" */ '../views/wms/warehouseLocation/warehouseLocation.vue')
  },
  {
    path: '/iotData',
    name: 'iotData',
    component: () => import('../views/mes/Iot/IotData.vue')
  },
  {
    path: '/equipmentProdLine',
    name: 'equipmentProdLine',
    component: () => import('../views/ems/equipmentProdLine/equipmentProdLine.vue')
  },
  {
    path: '/equipmentProdLine2',
    name: 'equipmentProdLine2',
    component: () => import('../views/ems/equipmentProdLine/equipmentProdLine2.vue')
  },
  {
    path: '/slottedAshIn',
    name: 'slottedAshIn',
    component: () => import('../views/wms/slottedAshIn/slottedAshIn.vue')
  },
  {
    path: '/slottedAshIn1',
    name: 'slottedAshIn1',
    component: () => import('../views/wms/slottedAshIn/slottedAshIn1.vue')
  },
  {
    path: '/emailPush',
    name: 'emailPush',
    component: () => import('../views/wms/emailPush/emailPush.vue')
  },
  {
    path: '/inputAndOutput',
    name: 'inputAndOutput',
    component: () => import('../views/wms/inputAndOutput/inputAndOutput.vue')
  },
  {
    path: '/inputAndOutput1',
    name: 'inputAndOutput1',
    component: () => import('../views/wms/inputAndOutput/inputAndOutput1.vue')
  },
  {
    path: '/productionData',
    name: 'productionData',
    component: () => import('../views/wms/productionData/productionData.vue')
  },
  {
    path: '/dailyCheck',
    name: 'dailyCheck',
    component: () => import('../views/wms/dailyCheck/dailyCheck.vue')
  },
  {
    path: '/dailyOutputCheck',
    name: 'dailyOutputCheck',
    component: () => import('../views/wms/dailyOutputCheck/dailyOutputCheck.vue')
  },
  {
    path: '/iotRealTime',
    name: 'iotRealTime',
    component: () => import('../views/iot/iotRealTime/iotRealTime.vue')
  },
  {
    path: '/iotHistorical',
    name: 'iotHistorical',
    component: () => import('../views/iot/iotHistorical/iotHistorical.vue')
  },
  {
    path: '/iotFigure',
    name: 'iotFigure',
    component: () => import('../views/iot/iotFigure/iotFigure.vue')
  },
  {
    path: '/agvTask',
    name: 'agvTask',
    component: () => import('../views/agv/agvTask.vue')
  },
  {
    path: '/statistics',
    name: 'statistics',
    component: () => import('../views/statistics/Statistics.vue')
  },
  {
    path: '/statisticsList/:tabname?',
    name: 'statisticsList',
    component: () => import('../views/statisticsList/index.vue')
  },
  {
    path: '/warehouse',
    name: 'warehouse',
    component: () => import('../views/warehouse/warehouse.vue')
  },
  {
    path: '/agv',
    name: 'agv',
    component: () => import('../views/mes/agv/index.vue')
  },
  {
    path: '/transferQuantity',
    name: 'transferQuantity',
    component: () => import('../views/transferQuantity/index.vue')
  },
  {
    path: '/warehouseEntry',
    name: 'warehouseEntry',
    component: () => import('../views/warehouseEntry/index.vue')
  },
  {
    path: '/ProductionLineMonitoring',
    name: 'ProductionLineMonitoring',
    component: () => import('../views/ProductionLineMonitoring/index.vue')
  },
  {
    path: '/generalView',
    name: 'generalView',
    component: () => import('../views/generalView/index.vue')
  },
  {
    path: '/agvDetails',
    name: 'agvDetails',
    component: () => import('../views/agv/agvDetails.vue')
  },
  {
    path: '/agvAlarmHistory',
    name: 'agvAlarmHistory',
    component: () => import('../views/agv/agvAlarmHistory.vue')
  },
  {
    path: '/allocationInforView',
    name: 'allocationInforView',
    component: () => import('../views/mes/allocationInforView/index.vue')
  },
  {
    path: '/ProductionLineDetails',
    name: 'ProductionLineDetails',
    component: () => import('../views/ProductionLineDetails/index.vue')
  },
  {
    path: '/tankBody',
    name: 'tankBody',
    component: () => import('../views/tankBody/index.vue')
  },
  {
    path: '/details',
    name: 'details',
    component: () => import('../views/tankBody/details.vue')
  },
  {
    path: '/InventoryDetails',
    name: 'InventoryDetails',
    component: () => import('../views/tankBody/InventoryDetails.vue')
  },
  {
    path: '/PreMixedDetails',
    name: 'PreMixedDetails',
    component: () => import('../views/tankBody/PreMixedDetails.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
router.beforeEach((to, from, next) => {
  /* 根据URL中的参数进行国际化处理 */
  // 1.存进 VUEX 状态管理 优先级：参数传递 > localStorage
  let lang = localStorage.getItem('lang') || 'zh_CN'
  const langMap = {
    en: 'en_US',
    es: 'es_US',
    'zh-cn': 'zh_CN',
  };

  if (to.query && to.query.lang && langMap[to.query.lang]) {
    lang = langMap[to.query.lang];
  }

  // 2.存到本地
  localStorage.setItem('lang', lang)
  next()
})
export default router
